package com.caizi.base.http;

/*
 * @author 菜菜籽
 * @date 2025/2/16 08:59
 * @description: Post请求
 */

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;

@Component
public class HttpPost extends Http {

    public <T> ResponseEntity<T> request(String endpoint, Object body, Class<T> responseType) {
        String url = getBaseUrl() + endpoint;
        return getRestTemplate().postForEntity(url, body, responseType);
    }

    public <T> ResponseEntity<T> requestWithFormData(String endpoint, MultiValueMap<String, String> formData, Class<T> responseType) {
        // 如果需要发送表单数据，请使用此方法
        String url = getBaseUrl() + endpoint;
        return getRestTemplate().postForEntity(url, formData, responseType);
    }
}